namespace Digitalmes.Application.Sys;

/// <summary>
/// 根据权限返回前端资源+指令权限
/// </summary>
public sealed class AuthorityDto
{
    /// <summary>
    /// 资源权限
    /// </summary>
    public List<AuthorityMenuDto>? Menu { get; set; } = new();

    /// <summary>
    /// 指令权限
    /// </summary>
    public List<string>? Directive { get; set; } = new();
}

/// <summary>
/// 返回给前端的权限菜单
/// </summary>
public sealed class AuthorityMenuDto
{
    /// <summary>
    /// 地址
    /// </summary>
    public string? path { get; set; }

    /// <summary>
    /// 组件
    /// </summary>
    [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
    public string? component { get; set; }

    /// <summary>
    /// 重定向
    /// </summary>
    [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
    public string? Redirect { get; set; }

    /// <summary>
    /// 名称
    /// </summary>
    public string? Name { get; set; }

    /// <summary>
    /// 属性
    /// </summary>
    public AuthorityMeta? Meta { get; set; }

    //public bool alwaysShow { get; set; } = true;

    /// <summary>
    /// 子级
    /// </summary>
    [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
    public List<AuthorityMenuDto>? Children { get; set; }
}

public sealed class AuthorityMeta
{
    /// <summary>
    /// 菜单名称
    /// </summary>
    [NotNull]
    public string? Title { get; set; }

    /// <summary>
    /// 图表
    /// </summary>
    public string? Icon { get; set; }

    public bool Affix { get; set; }

    [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
    public string? Type { get; set; }

    /// <summary>
    /// 是否显示
    /// </summary>
    public bool? Hidden { get; set; }

    [JsonIgnore]
    public bool? DynamicNewTab { get; set; }

    /// <summary>
    /// 是否全屏
    /// </summary>
    public bool? Fullpage { get; set; }

    /// <summary>
    /// 是否关闭
    /// </summary>
    [JsonIgnore]
    public bool NoClosable { get; set; }

    //不缓存
    [JsonIgnore]
    public bool NoKeepAlive { get; set; }

    /// <summary>
    /// 按钮权限
    /// </summary>
    [JsonIgnore]
    public string[]? Roles { get; set; }
}
